/**
 * 创建者：luyiming
 * 该组件用于：
 * 创建时间： 2019-12-24 17:55:43
 * @param 参数说明
 * @emit 事件使用说明
 */

import {
	rcimTree
} from '@/api/RCIM/RCIM-system.js';
import ScrollPane from '@/components/luyiming/ScrollPane/ScrollPane.vue'
export default {
	name: 'SystemTree_cmp',
	components: {
		ScrollPane
	},
	props: {
		// 这是示例数据的通途
		example: {
			type: Array,
			default: () => []
		},
		data: {
			type: Array,
			default: () => []
		},
		setDefExtendId: {
			type: String,
			default: () => ''
		},
	},
	// 数据
	data() {
		return {
			filterText: '',
			treeProps: {
				label: 'name',
			},
			// 初始化被选中的节点
			currentNodeKey: "EnterpriseInfo",
			// 初始化默认展开的树节点数组
			defaultExpand: [],
		}
	},
	// 监听
	watch: {
		data(value) {
			// debugger
			this.$nextTick(() => {
				
				this.currentNodeKey = value[0].id;
				const node = this.$refs.tree.getCurrentNode()
				const Node = this.$refs.tree.getNode(node)
				const tree = this.$refs.tree
				this.treeHandle(node, Node, tree)
			})

		},
		setDefExtendId(value){
			this.$refs.tree.setCurrentKey(value)
		}
	},
	// Vue实例初始化完成
	created() {},
	// Vue挂载完成
	mounted() {
		// debugger
		this.$nextTick(() => {
			
			this.$attrs.currentKey ? this.$refs.tree.setCurrentKey(this.$attrs.currentKey) : this.$refs.tree.setCurrentKey(this.setDefExtendId);
			const node = this.$refs.tree.getCurrentNode()
			const Node = this.$refs.tree.getNode(node)
			const tree = this.$refs.tree
			this.treeHandle(node, Node, tree)

		})

	},
	// Vue实例销毁前
	beforeDestroy() {

	},
	// 挂载的方法
	methods: {
		/**
		 * 方法描述
		 */
		exampleFunc() {
			return void 0
		},
		/**
		 * 树的点击
		 */
		treeHandle(...rest) {
			this.$emit('handleEvent', ...rest)
		},
	},
}
